#!/usr/bin/env ./jsrun

var n = 0;

var load_async = function(url, f) {
	var id = n++;
	setTimeout(function(){
		var x = curlLoad('http://localhost');
		f(id);
		delete x;
		n--;
	}, 0);
	//return id;
};

var run_test = function(){
	//var req = new Http();
	setTimeout(function(){
		//t0 = +new Date;
		//var thread_id = n++;
		var t0 = +new Date;
		load_async('http://localhost/test/phpinfo.php', function(id){
			//alert('\n\nHEADER\n===========================\n');
			//alert('header: '+x + '\n' + y);
			var t = +new Date - t0;
			alert('thread ' + id + ' done with time: ' + t + ' ms.');
			setTimeout(function(){run_test()}, 10);
		});
		//alert('size: ' + x.length);
		
	}, 0);
};


setTimeout(function(){
	make(run_test, 3);
}, 100);
	


sleep(100000);
